package com.whh.tq;

import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.util.Log;

import com.whh.tq.common.AndroidHelper;

public class SettingActivity extends PreferenceActivity {
	private CheckBoxPreference cbFlashLight;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.setting);
		init();
		setListener();
	}
	
	private void init(){
		cbFlashLight = (CheckBoxPreference)findPreference(AndroidHelper.PREF_KEY_FLASHLIGHT);
	}
	
	private void setListener(){
		cbFlashLight.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
			@Override
			public boolean onPreferenceChange(Preference pref, Object newValue) {
				Log.i(AndroidHelper.LOG_TAG,AndroidHelper.PREF_KEY_FLASHLIGHT+":"+newValue);
				return true;
			}
		});
	}
	
	@Override
	public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,Preference preference) {
		Log.i(AndroidHelper.LOG_TAG,"key:"+preference.getKey());
		return super.onPreferenceTreeClick(preferenceScreen, preference);
	}
}
